package org.icosagon.core.items;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.icosagon.core.InvalidNumberException;

/**
 *
 * @author Daniel Owens
 */
@XmlRootElement(name="cost")
public class Cost {
    private String type = "copper";
    private int amount = 0;

    public void setDenomination(String value) {
        this.type = value.trim();
    }

    @XmlElement(name="denomination")
    public String getDenomination() {
        return this.type;
    }

    public void setAmount(int value) {
        if(value < 0)
            throw new InvalidNumberException("There can not be negitave money.");
        else
            this.amount = value;
    }

    @XmlElement(name="amount")
    public int getAmount() {
        return this.amount;
    }

    @Override public String toString() {
        return String.valueOf(this.amount)+" "+this.type;
    }
}